<template>
  <el-button :size="global.gSize" :type="type" :icon="icon" style="padding:2px 7px" :loading="loading"
    v-if="hasPerms(perms)" @click="handleClick" :title="$t('action.delete')">

  </el-button>
</template>

<script>
import { hasPermission } from '@/permission/index.js'
export default {
  name: 'KtButton',
  props: {
    label: {  // 按钮显示文本
      type: String,
      default: '删除'
    },
    icon: {  // 按钮显示图标delete
      type: String,
      default: 'fa fa-trash'
    },

    type: {  // 按钮类型
      type: String,
      default: "danger"
    },
    loading: {  // 按钮加载标识
      type: Boolean,
      default: false
    },
    disabled: {  // 按钮是否禁用
      type: Boolean,
      default: false
    },
    perms: {  // 按钮权限标识，外部使用者传入
      type: String,
      default: null
    }
  },
  data() {
    return {
    }
  },
  methods: {
    handleClick: function () {
      this.$confirm(this.$t('action.isDelete'), this.$t('action.tips'), {
        type: 'warning'
      }).then(() => {
        this.$emit('click', {})
      }).catch(() => {
      })
    },

    hasPerms: function (perms) {
      // 根据权限标识和外部指示状态进行权限判断
      return hasPermission(perms) & !this.disabled
    }
  },
  mounted() {
  }
}
</script>

<style scoped></style>